// ...existing code...

@app.route('/apply_job', methods=['GET', 'POST'])
def apply_job():
    if request.method == 'POST':
        try:
            # 获取表单数据
            form_data = request.form.to_dict()
            
            # 基本验证
            required_fields = ['name', 'student_id', 'position']
            for field in required_fields:
                if not form_data.get(field):
                    flash('请填写所有必填项', 'error')
                    return redirect(url_for('apply_job'))
            
            # 处理表单数据
            # ...existing code...
            
            flash('申请提交成功！', 'success')
            return redirect(url_for('index'))
            
        except Exception as e:
            flash('申请提交失败，请稍后重试', 'error')
            return redirect(url_for('apply_job'))
            
    return render_template('job_application.html')

// ...existing code...
